<template>
    <div>
        <Table
                highlight-row
                :columns="columns"
                :data="data">
            <template slot-scope="{ row, index }" slot="action">
                <radio-component @getVal="getValData" :key="row.bId" :bId="row.bId" slot="action"></radio-component>
            </template>
        </Table>
    </div>
</template>

<script>
    import RadioComponent from '@/view/blog/commentary/RadioComponent'
    export default {
        name: "ListUnverifyCommentary",
        components: {
            RadioComponent
        },
        data() {
            return {
                columns: [
                    {
                        title: '评论人',
                        key: 'member'
                    },
                    {
                        title: '评论内容',
                        key: 'content'
                    },
                    {
                        title: '评论IP',
                        key: 'ip',
                        width: 120
                    },
                    {
                        title: '未审核',
                        slot: 'action',
                        width: 100
                    }
                ],
                data: [],
                cId:"0"
            }
        },
        methods: {
            getValData(val) {
                console.log(val);
                this.$http({
                    method: 'post',
                    url: this.apiBase + '/blog/commentary/update',
                    data: {
                        bId:val.bId,
                        state:val.status
                    }
                })
                    .then(response => {
                        this.listUnverify(this.$route.params.aId);
                    })
                    .catch(error => {
                        console.log(error);
                    })
            },
            listUnverify(val) {
                console.log(val);
                this.$http({
                    method: 'post',
                    url: this.apiBase + '/blog/commentary/list/'+val,
                    data: {}
                })
                    .then(response => {
                        this.data = response.data.data.comments;
                        console.log(this.data)
                    })
                    .catch(error => {
                        console.log(error);
                    })
            }
        },
        mounted() {
            this.listUnverify(this.$route.params.aId);
        }
    }
</script>

<style scoped>

</style>